#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 4e5 + 10;

int n, m;
int A[N], eq[N], cur[N];
unordered_map<int, int> idx;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    for(int i = 1; i <= m; i ++) cin >> A[i];
    for(int i = 1; i <= n; i ++) eq[i] = cur[i] = i;

    for(int i = 1; i <= m; i ++){
        swap(eq[A[i]], eq[A[i] + 1]);
    }
    
    // for(int i = 1; i <= n; i ++) cout << eq[i] << " ";
    // cout << '\n';

    for(int i = 1; i <= n; i ++) idx[eq[i]] = i;


    for(int i = 1; i <= m; i ++){
        int t = A[i];
        if(cur[t] == 1){
            cout << idx[cur[t + 1]] << '\n';
        }else if(cur[t + 1] == 1){
            cout << idx[cur[t]] << '\n';
        }else{
            cout << idx[1] << '\n';
        }
        swap(cur[t], cur[t + 1]);
    }




    return 0;
}